package com.ccp.dev.qbdms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.api.ISysUser;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.response.ResultData;
import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.basic.util.PropertyUtil;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.poi.excel.reader.TableEntity;
import com.ccp.dev.core.util.BeanUtils;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.extend.service.ExtendSysOrgService;
import com.ccp.dev.qbdms.consts.ZhiLiangConst;
import com.ccp.dev.qbdms.enums.FlowStatusEnum;
import com.ccp.dev.qbdms.expimp.CustomExcelReader;
import com.ccp.dev.qbdms.expimp.util.AbstractExpUtil;
import com.ccp.dev.qbdms.expimp.util.AbstractImpUtil;
import com.ccp.dev.qbdms.expimp.util.AuxiliaryUtil;
import com.ccp.dev.qbdms.model.WQbdTrustTeam;
import com.ccp.dev.qbdms.service.CommonalityService;
import com.ccp.dev.qbdms.service.WQbdTrustTeamService;
import com.ccp.dev.qbdms.util.BaseUtil;
import com.ccp.dev.qbdms.util.ProjectUUIDUtils;
import com.ccp.dev.qbdms.util.StructureModifyUtil;
import com.ccp.dev.system.model.SysOrg;
import com.ccp.dev.system.model.SysUser;
import com.ccp.dev.system.service.SysOrgService;
import com.ccp.dev.workflow.model.ProcessRun;
import com.ccp.dev.workflow.model.TaskOpinion;
import com.ccp.dev.workflow.model.bpm.ProcessCmd;
import com.ccp.dev.workflow.service.ProcessRunService;
import com.ccp.dev.workflow.service.TaskOpinionService;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Date;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 质量信得过班组管理 信息操作处理控制器
 *
 * @author zhl
 * @date 2020-07-03 10:05:15
 */
@Controller
/**
 * 请将此名称添加到日志开关
 */
@Action(customModel = "质量信得过班组管理")
@RequestMapping("/qbdms/wQbdTrustTeam")
public class WQbdTrustTeamController extends SysBaseController{
	@Resource
	private WQbdTrustTeamService wQbdTrustTeamService;
    @Resource
    private ExtendSysOrgService extendSysOrgService;
    @Resource
    private SysOrgService sysOrgService;
    @Resource
    private CommonalityService commonalityService;
    @Resource
    private ProcessRunService processRunService;
    @Resource
    private TaskOpinionService taskOpinionService;

    /**
     * 功能描述: 跳转到首页
     *
     * @return: java.lang.String
     * @auther: zhl
     * @date: 2020-07-03 10:05:15
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_LIST)
    @Action(description="跳转到质量信得过班组管理首页", exectype = "页面跳转日志")
    public String viewList(ModelMap modelMap) {
        // 当前系统等级
        BaseUtil.SystemLevel currentSystemLevel = BaseUtil.getCurrentSystemLevel();
        modelMap.put("currentSystemLevel", currentSystemLevel);
        modelMap.put("currentUserId", ContextUtil.getCurrentUserId());

        return "wQbdTrustTeam/list";
    }

    /**
    * 功能描述: 附带检索条件的分页查询
    *
    * @param: [request] http请求
    * @return: java.lang.Object
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_LIST)
    @ResponseBody
    @Action(description="附带检索条件的分页查询质量信得过班组管理",detail="查询数据信息<#if success>成功<#else></#if>")
    public Object list(HttpServletRequest request) throws IllegalAccessException {
        QueryFilter queryFilter = new QueryFilter(request, true);
        // 默认按照评定时间倒序排列,评定时间相同的情况下按创建时间倒序排列
        if (StringUtil.isEmpty(queryFilter.get("orderField"))) {
            queryFilter.addFilter("orderField", "CREATETIME");
            queryFilter.addFilter("orderSeq", "desc");
        }
        ZhiLiangConst.addQueryFilter(queryFilter);

        //分页数据
        List<WQbdTrustTeam> pageDatas = wQbdTrustTeamService.queryList(queryFilter);
        // 密级、上报状态、数据来源单位显示中文
        ZhiLiangConst.showName(pageDatas);
        // 添加编辑按钮权限控制
        ZhiLiangConst.isDataAllowEditByFlowStatus(pageDatas);

        SysAuditThreadLocalHolder.putParamerter("success",true);
        return success(pageDatas, queryFilter.getPageBean().getTotalCount());
    }


    /**
     * 功能描述: 跳转到新增页面
     *
     * @return: java.lang.String
     * @auther: zhl
     * @date: 2020-07-03 10:05:15
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_ADD_UPDATE)
    @Action(description="跳转到质量信得过班组管理新增页面", exectype = "页面跳转日志")
    public String viewAdd(HttpServletRequest request,ModelMap modelMap) {
        String id = RequestUtil.getString(request,"id");
        modelMap.put("id",id);
        if (StringUtil.isEmpty(id)) {
            ISysUser currentUser = ContextUtil.getCurrentUser();
            String userId = currentUser.getUserId();
            SysOrg currentTenOrg = extendSysOrgService.getTenOrg(userId);
            modelMap.put("filldept", currentTenOrg.getOrgName());
            modelMap.put("filldeptid", currentTenOrg.getCode());
        }else{
          WQbdTrustTeam wQbdTrustTeam = wQbdTrustTeamService.getOneById(id);
          modelMap.put("flowStatus", wQbdTrustTeam.getFlowStatus());
        }
        String flag = RequestUtil.getString(request, "flag");
        modelMap.put("flag", flag);
        String runId="";
        List<TaskOpinion> taskOpinionNewList = new ArrayList<TaskOpinion>();
        ProcessRun processRun=processRunService.getByBusinessKey(id);
        if(BeanUtils.isNotEmpty(processRun)){
            runId=processRun.getRunId();
            List<TaskOpinion> taskOpinionList = taskOpinionService.getByRunId(runId);
            for(TaskOpinion taskOpinion:taskOpinionList){
                if(taskOpinion.getEndTime()!=null){
                    taskOpinionNewList.add(taskOpinion);
                }
            }
        }
        modelMap.put("taskOpinionNewList", taskOpinionNewList);
        modelMap.put("researchRoomList", JSON.toJSONString(sysOrgService
            .querySubSysOrgBySupOrgIdNoChild(sysOrgService.getSysOrgByOrgCode("wrj").getOrgId())));
        modelMap.put("fileManagementUploadType", PropertyUtil.getByAlias("fileManagementUploadType", ""));
        modelMap.put("wjszsdsxlx", PropertyUtil.getByAlias("wjszsdsxlx", ""));

        return "wQbdTrustTeam/add";
    }

    /**
    * 功能描述:  数据保存通用方法
    *
    * @param: wQbdTrustTeam 保存的对象
    * @return: java.lang.Object
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_SAVE)
    @ResponseBody
    @Action(description="保存质量信得过班组管理数据",detail="<#if isAdd>新增<#else>编辑</#if>质量信得过班组管理数据<#if success>成功<#else>失败</#if><#if StringUtil.isNotEmpty(modifyInfo)>${modifyInfo}</#if>")
    public Object save(@RequestBody WQbdTrustTeam wQbdTrustTeam) {
        Date createTime =wQbdTrustTeam.getCreateTime();
        String id = wQbdTrustTeam.getId();
        int result;
        if (StringUtil.isEmpty(id)) {
            SysAuditThreadLocalHolder.putParamerter("isAdd",true);
            //新增操作
            //新增数据前生成随机Id
            wQbdTrustTeam.setId(ProjectUUIDUtils.getUUIDFor32());
            ZhiLiangConst.addCommonFields(wQbdTrustTeam);
            //上报状态&评定状态
            BaseUtil.SystemLevel currentSystemLevel = BaseUtil.getCurrentSystemLevel();
            if (BaseUtil.SystemLevel.HOSPITALLEVEL.equals(currentSystemLevel)) {
                wQbdTrustTeam.setEvaluatestatus("通过");
                wQbdTrustTeam.setReportStatus(ZhiLiangConst.REPORT_STATUS_GROUPTOBEREPORTED);
            } else if (BaseUtil.SystemLevel.PLANTLEVEL.equals(currentSystemLevel)) {
                wQbdTrustTeam.setEvaluatestatus("待评定");
                wQbdTrustTeam.setReportStatus(ZhiLiangConst.getDataInitStatusToHospital());
            }
            wQbdTrustTeam.setFlowStatus(FlowStatusEnum.NOT_SUBMIT.getValue());
            wQbdTrustTeam.setCreateTime(createTime);
            result = wQbdTrustTeamService.add(wQbdTrustTeam);
        } else {
            SysAuditThreadLocalHolder.putParamerter("success",false);
            ZhiLiangConst.updateCommonFields(wQbdTrustTeam);
            //修改操作
            wQbdTrustTeam.setCreateTime(createTime);
            result = wQbdTrustTeamService.update(wQbdTrustTeam);
            SysAuditThreadLocalHolder.putParamerter("modifyInfo", StructureModifyUtil.getModifyInfo(wQbdTrustTeamService.getOneById(id), wQbdTrustTeam));

        }
        if(result > 0){
            SysAuditThreadLocalHolder.putParamerter("success",true);
        }else{
            SysAuditThreadLocalHolder.putParamerter("success",false);
        }
        Map<String,Object> idMap= Maps.newHashMap();
        idMap.put("id",wQbdTrustTeam.getId());
        return result > 0 ? getResultDataSuccess("save.success",idMap) : getResultDataError("save.failure");
    }

    /**
    * 功能描述: 跳转到详情页面
    *
    * @return: java.lang.String
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/particulars")
    @Action(description="跳转到质量信得过班组管理详情页面", exectype = "页面跳转日志")
    public String viewParticulars(HttpServletRequest request,ModelMap modelMap) {
        String flag = RequestUtil.getString(request, "flag");
        modelMap.put("flag", flag);
        String id = RequestUtil.getString(request,"id");
        modelMap.put("id",id);
        String runId="";
        List<TaskOpinion> taskOpinionNewList = new ArrayList<TaskOpinion>();
        ProcessRun processRun=processRunService.getByBusinessKey(id);
        if(BeanUtils.isNotEmpty(processRun)){
            runId=processRun.getRunId();
            List<TaskOpinion> taskOpinionList = taskOpinionService.getByRunId(runId);
            for(TaskOpinion taskOpinion:taskOpinionList){
                if(taskOpinion.getEndTime()!=null){
                    taskOpinionNewList.add(taskOpinion);
                }
            }
        }
        modelMap.put("taskOpinionNewList", taskOpinionNewList);
        WQbdTrustTeam wQbdTrustTeam = wQbdTrustTeamService.getOneById(id);
        modelMap.put("flowStatus", wQbdTrustTeam.getFlowStatus());
        modelMap.put("runId", runId);
        return "wQbdTrustTeam/particulars";
    }

    /**
    * 功能描述: 根据主键id获取一条数据的通用查询方法
    *
    * @param: id 参数对象必须是"id"
    * @return: java.lang.Object
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_GET)
    @ResponseBody
    @Action(description="根据主键id查询质量信得过班组管理的一条数据",detail="根据主键id查询质量信得过班组管理的数据<#if success>成功<#else>失败</#if>")
    public Object get(@RequestParam("id") String id) {
        WQbdTrustTeam wQbdTrustTeam = wQbdTrustTeamService.getOneById(id);
        if (null == wQbdTrustTeam) {
            SysAuditThreadLocalHolder.putParamerter("success",false);
            return getResultDataError("get.failure");
        }
        SysAuditThreadLocalHolder.putParamerter("success",true);
        return getResultDataSuccess("get.success",wQbdTrustTeam);
    }

    /**
    * 功能描述: 根据主键ID删除数据的通用删除方法
    *
    * @param: id 参数名称必须是"id"
    * @return: java.lang.Object
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @PostMapping(UrlConstants.MODULE_FUNCTION_DELETE)
    @ResponseBody
    @Action(description="根据主键ID删除质量信得过班组管理数据",exectype = "删除日志",detail="删除数据信息<#if success>成功<#else>失败</#if>")
    public Object delete(@RequestParam("id") String id) throws Exception{
        String userId = ContextUtil.getCurrentUserId();
        String[] ids = id.split(",");
        for (String key : ids) {
            WQbdTrustTeam wQbdTrustTeam = wQbdTrustTeamService.getOneById(key);
            if (!userId.equals(wQbdTrustTeam.getCreateBy())) {
                SysAuditThreadLocalHolder.putParamerter("success", false);
                return fail("删除失败！只能删除自己创建的数据！");
            }
            if (!FlowStatusEnum.getEnumByValue(wQbdTrustTeam.getFlowStatus()).isDel()) {
                SysAuditThreadLocalHolder.putParamerter("success", false);
                return fail("删除失败！不允许删除流程未结束数据！");
            }
//            if (Objects.nonNull(wQbdTrustTeam.getReportStatus()) && !ZhiLiangConst.REPORT_STATUS_TEMP_TOBEREPORTED.equals(wQbdTrustTeam.getReportStatus()) && !ZhiLiangConst.REPORT_STATUS_GROUPTOBEREPORTED.equals(wQbdTrustTeam.getReportStatus())) {
//                SysAuditThreadLocalHolder.putParamerter("success", false);
//                return fail("删除失败，只允许删除待上报的数据");
//            }
        }
        //流程实例删除
        for (String key : ids) {
            WQbdTrustTeam wQbdTrustTeam = wQbdTrustTeamService.getOneById(key);
            if(!wQbdTrustTeam.getFlowStatus().equals(FlowStatusEnum.NOT_SUBMIT.getValue()) && StringUtil.isNotEmpty(wQbdTrustTeam.getFlowStatus())){
                ProcessRun processRun = processRunService.getByBusinessKey(key);
                if(processRun!=null){
                    processRunService.deleteByProcessRun(processRun);
                }
            }
        }
        if (StringUtil.isEmpty(id)) {
            SysAuditThreadLocalHolder.putParamerter("success",false);
            return fail("delete.failure.message");
        }
        int result = wQbdTrustTeamService.delByIdArray(id.split(","));
        if(result > 0){
            SysAuditThreadLocalHolder.putParamerter("success",true);
        }else{
            SysAuditThreadLocalHolder.putParamerter("success",false);
        }
        return result > 0 ? getResultDataSuccess("delete.success") : getResultDataError("delete.failure");
    }


    /**
    * 功能描述: 跳转到导入页面
    *
    * @return: java.lang.String
    * @auther: hw
    * @date: 2019-12-25 19:21:40
    */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/import")
    @Action(description="跳转到质量信得过班组管理导入页面", exectype = "页面跳转日志")
    public String viewImport() {
        return "wQbdTrustTeam/import";
    }



    /**
     * 功能描述: 跳转到导出选择字段页面
     *
     * @return: java.lang.String
     * @auther: hw
     * @date: 2019-12-25 19:21:40
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/export")
    @Action(description = "跳转到质量信得过班组字段页面", exectype = "页面跳转日志")
    public String export(HttpServletRequest request, ModelMap modelMap) throws Exception {
        com.alibaba.fastjson.JSONObject jsonObject = AuxiliaryUtil.resolverModel(WQbdTrustTeam.class);
        modelMap.put("tableInfo", jsonObject.toString());
        return "expImp/add";
    }

    /**
    * 功能描述: 导出质量信得过班组管理数据信息
    *
    * @param: [request] http请求
    * @return: java.lang.Object
    * @auther: zhl
    * @date: 2020-07-03 10:05:15
    */
    @RequestMapping("/exportData")
    @Action(description="导出质量信得过班组管理数据信息",detail="导出质量信得过班组管理数据信息<#if success>成功<#else></#if>")
    public void export(HttpServletRequest request, HttpServletResponse response) throws Exception{
        SysAuditThreadLocalHolder.putParamerter("success", false);
        String[] id = RequestUtil.getStringAryByStr(request, "id");
        QueryFilter queryFilter = new QueryFilter(request, false);
        // 默认按照创建时间倒序排列
        if (StringUtil.isEmpty(queryFilter.get("orderField"))) {
            queryFilter.addFilter("orderField", "CREATETIME");
            queryFilter.addFilter("orderSeq", "desc");
        }
        JSONArray dataArray = ZhiLiangConst.exportAddConditions(queryFilter,id);
        List<WQbdTrustTeam> wQbdQcGroups = this.wQbdTrustTeamService.queryAll(queryFilter);
        if (wQbdQcGroups.isEmpty()) {
            wQbdQcGroups.add(new WQbdTrustTeam());
        }
        new AbstractExpUtil() {
            @Override
            public String customAnalysis(String fieldName, String fieldValue) {
                return null;
            }
        }.executeExport(request, response, wQbdQcGroups, dataArray, AbstractExpUtil.ExpStyle.MANY_SHEET);
        SysAuditThreadLocalHolder.putParamerter("success", true);
    }

    /**
    * 导入资源文件
    * @param request
    * @param response
    * @throws Exception
    */
    @RequestMapping("/importData")
    @ResponseBody
    @Action(description = "导入QC小组", detail = "导入QC小组<#if success>成功<#else></#if>")
    public ResultData importData(MultipartHttpServletRequest request, HttpServletResponse response) throws Exception{
        SysAuditThreadLocalHolder.putParamerter("success", false);
        MultipartFile multipartFile = request.getFile("file");
        TableEntity excelEntity = new CustomExcelReader().readFile(multipartFile.getInputStream());
        Map<String, Object> map = new AbstractImpUtil() {
            @Override
            public ReturnType customValidation(String fieldName, String fieldValue) {
                ReturnType returnType = null;
                // 校验位置
                if ("teamdeptid".equals(fieldName)) {
                    returnType = new ReturnType();
                    List<SysOrg> sysOrgs = sysOrgService.queryByOrgName(fieldValue);
                    if (sysOrgs.size() > 0) {
                        SysOrg sysOrg = sysOrgs.get(0);
                        if (StringUtil.isNotEmpty(sysOrg.getCode())) {
                            returnType.setNewValue(sysOrg.getCode());
                        } else {
                            returnType.setNewValue("");
                        }
                    } else {
                        returnType.setMsg("当前系统没有所填单位！");
                    }
                }

                if("teamcount".equals(fieldName)){
                    boolean matches = fieldValue.matches("^[1-9]+[0-9]*$");
                    if (!matches) {
                        returnType = new ReturnType();
                        returnType.setMsg("只能输入非负整数！");
                    }
                }

                if("money".equals(fieldName)){
                    boolean matches = fieldValue.matches("^((0\\.\\d{1,2})|([1-9]\\d*\\.\\d{1,2})|([1-9]+\\d*))$");
                    if (!matches) {
                        returnType = new ReturnType();
                        returnType.setMsg("只能输入数字且小数最多两位！");
                    }
                }

                return returnType;
            }
        }.reverseModels(excelEntity, WQbdTrustTeam.class);
        String msg = map.get("msg").toString();
        List<WQbdTrustTeam> list = (List<WQbdTrustTeam>) map.get("instList");
        if (StringUtil.isEmpty(msg)) {
            this.wQbdTrustTeamService.addImportData(list);
            SysAuditThreadLocalHolder.putParamerter("success", true);
            return getResultDataSuccess("dataSource.importXml.success");
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
            return fail(msg);
        }
    }



    /**
     * 查询上报的信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/reportList")
    @ResponseBody
    public Object reportList(HttpServletRequest request, @RequestParam("id") String id) {
        String[] ids = RequestUtil.getStringAryByStr(request, "id");
        QueryFilter queryFilter = new QueryFilter(request, false);
        queryFilter.clear();
        queryFilter.addFilter("byId", true);
        queryFilter.addFilter("id", ids);
        List<WQbdTrustTeam> wQbdTrustTeamList = wQbdTrustTeamService.queryAll(queryFilter);
//        boolean isAllowReport = wQbdTrustPeopleList.stream().allMatch(wQbdTrustPeople -> "待评定".equals(wQbdTrustPeople.getEvaluatestatus()));
        boolean isAllowReport = wQbdTrustTeamList.stream().allMatch(wQbdTrustPeople -> ZhiLiangConst.getDataInitStatusToHospital().equals(wQbdTrustPeople.getReportStatus()));
        if (!isAllowReport) {
            return new ResultData(1, "所选数据存在不允许上报状态", 0L, null);
        } else {
            wQbdTrustTeamList.forEach(wQbdTrustPeople -> wQbdTrustPeople.setReportStatus(ZhiLiangConst.REPORT_STATUS_GROUPTOBEREPORTED));
            return wQbdTrustTeamService.reportList(wQbdTrustTeamList);
        }
    }
    /**
     * 功能描述:  数据评定方法
     *
     * @param: wQbdTrustPeople 评定的对象
     * @return: java.lang.Object
     * @auther: 王明亮
     * @date: 2020-07-02 15:30:24
     */
    @RequestMapping("/evaluate")
    @ResponseBody
    @Action(description = "评定质量信得过班组管理数据", detail = "评定质量信得过班组管理数据<#if success>成功<#else>失败</#if>")
    public Object evaluate(@RequestBody WQbdTrustTeam wQbdTrustTeam) {
        boolean isSuccess = commonalityService.evaluate("wQbdTrustTeam", wQbdTrustTeam);
        int result = 0;
        if (isSuccess) {
            result = wQbdTrustTeamService.update(wQbdTrustTeam);
        } else {
            return new ResultData(1, "评定失败，API接口调用失败!", 0L, null);
        }
        if (result > 0) {
            SysAuditThreadLocalHolder.putParamerter("success", true);
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
        }
        return result > 0 ? new ResultData(0, "评定成功", 0L, null) : new ResultData(1, "评定失败", 0L, null);
    }

    /**
     * 功能描述: 启动流程
     */
    @PostMapping("/run")
    @ResponseBody
    @Action(description="启动质量信得过班组管理流程",detail="启动流程<#if success>成功<#else></#if>")
    public Object run(HttpServletRequest request,@RequestBody WQbdTrustTeam wQbdTrustTeam){
        SysUser sysUser = (SysUser) ContextUtil.getCurrentUser();
        //实体主键
        String id = wQbdTrustTeam.getId();
        int isList = RequestUtil.getInt(request,"isList",1);
        ProcessCmd processCmd = new ProcessCmd();
        //流程Key
        processCmd.setModelKey("zlxdgbzsplc");
        processCmd.setUserAccount(sysUser.getAccount());
        try {
            if(isList == 1){
                wQbdTrustTeam = wQbdTrustTeamService.getOneById(id);
            }
            processCmd.setBusinessKey(id);
            processRunService.startProcess(processCmd);
            wQbdTrustTeam.setFlowStatus(FlowStatusEnum.APPROVAL_ING2.getValue());
            wQbdTrustTeamService.update(wQbdTrustTeam);
            SysAuditThreadLocalHolder.putParamerter("success",true);
            return getResultDataSuccess("flow.start.success");
        } catch (Exception e) {
            SysAuditThreadLocalHolder.putParamerter("success",false);
            return getResultDataError("flow.start.failure");
        }
    }


}
